package com.bawei.opengldemo;

import android.os.Bundle;

import android.view.ViewGroup;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class TexttureActivity extends AppCompatActivity {

    private WlGLTextureView wlGLTextureView;
    private LinearLayout lyContent;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_texture);
        wlGLTextureView = findViewById(R.id.wlglsurfaceviw);
        lyContent = findViewById(R.id.ly_content);

        wlGLTextureView.getWlTextureRender().setOnRenderCreateListener(new WlTextureRender.OnRenderCreateListener() {
            @Override
            public void onCreate(final int textid) {

                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {

                        if(lyContent.getChildCount() > 0)
                        {
                            lyContent.removeAllViews();
                        }

                        for(int i = 0; i <3; i ++)
                        {
                            WlMutiSurfaceVeiw wlMutiSurfaceVeiw = new WlMutiSurfaceVeiw(TexttureActivity.this);
                            wlMutiSurfaceVeiw.setTextureId(textid, i);
                            wlMutiSurfaceVeiw.setSurfaceAndEglContext(null, wlGLTextureView.getEglContext());

                            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
                            lp.width = 200;
                            lp.height = 300;
                            wlMutiSurfaceVeiw.setLayoutParams(lp);

                            lyContent.addView(wlMutiSurfaceVeiw);
                        }
                    }
                });

            }
        });

    }
}
